/**
 * 
 */
package de.oszimtcc.timetableview;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.ViewFlipper;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView.OnItemClickListener;
import de.oszimtcc.framework.BaseActivity;
import de.oszimtcc.timetable.R;
import de.oszimtcc.timetable.TimetableApplication;
import de.oszimtcc.timetableadapter.DayAdapter;
import de.oszimtcc.timetablecore.Block;
import de.oszimtcc.timetablecore.Timetable;
import de.oszimtcc.timetablehelper.ViewFlipperGestureDetector;
import de.oszimtcc.timetablescreens.BlockDetailScreen;
import de.oszimtcc.timetableview.DefaultGestureFilter.SimpleGestureListener;


/**
 * @author reuter
 *
 */
public class TimetableFlipperView extends ViewFlipper
{
	private Timetable timetable;
	private BlockListView blockListView;
	private BaseActivity activity;
	
	public TimetableFlipperView(Context context)
    {
	    super(context);
    }

	public TimetableFlipperView(Context context, AttributeSet attrs)
    {
	    super(context, attrs);
    }
	
	public void AddContent(Timetable pTimetable)
	{
		this.timetable = pTimetable;
		this.activity = TimetableApplication.getInstance().getActivity();
		
    	for (int i = 0; i < timetable.getDayList().size(); i++)
    	{
    		LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    		LinearLayout changes = new LinearLayout(this.getContext());
    		changes.setLayoutParams(lp);
    		changes.setOrientation(LinearLayout.VERTICAL);
    		changes = (LinearLayout) activity.inflater.inflate(R.layout.daily_content, null); 
    		
    		blockListView = (BlockListView) changes.findViewById(R.id.dayListView);
    		blockListView.AddContent(this);
			DayAdapter dayListAdapter = new DayAdapter(this.activity, i, pTimetable.getDayList().get(i).BlockList);
			blockListView.setAdapter(dayListAdapter);
			this.addView(changes);
    	}
	}
}
